﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

namespace Hosting.Class
{
    public class ConnectionDB
    {

        public static SqlConnection con;

        // Specification in the connection string:
        // Please note: Pooling is implicit, you automatically get it unless you disable it. 
        //              Therefore, "true" is the default for the pooling keyword (pooling=true).   
        // Connection Reset:    False
        // Connection Lifetime: 5
        // Enlist:              true
        // Min Pool Size:       1
        // Max Pool Size:       50

        public bool isConnection()
        {
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
            builder.DataSource = @"THEBAD\PC";
            builder.InitialCatalog = "HostDomainWebsite";
            builder.UserID = "sa";
            builder.Password = "123456";
            builder.MinPoolSize = 1;
            builder.MaxPoolSize = 20;
            builder.ConnectTimeout = 2;
            builder.Pooling = true;

            con = new SqlConnection(builder.ConnectionString);

            return con == null ? false : true;
        }

        public void close()
        {
            ConnectionDB.con.Close();
        }
    }
}